home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / utility / bfind707.zip / BFIND.DOC next >
Text File  |  1997-07-31  |  20KB  |  433 lines

  1. BFIND.DOC                              1                           Jul 31, 1997
  2.  
  3. WIN95 AND WINNT NOTICE:  As with most DOS-based utilities, this program doesn't
  4. understand the weird subdirectories, long filenames,  invalid  characters  that
  5. are possible under Windows 95 and Windows/NT.   Both  operating  systems  alias
  6. long filenames into names like MYFILE~1.TXT and you will need  to  specify  the
  7. aliased versions of file names to process  them.   Under  some  file  structure
  8. systems in NT, the program may not work at all.
  9.  
  10. The BFIND.EXE program adds Boolean logic to DOS's FIND command.  In most  ways,
  11. it's identical to the FIND command except:
  12.  
  13.   * Adds AND, OR, NOT, and XOR options to  searches  (finding  all  lines  with
  14.     "Apples" or "Bananas", for example).
  15.   * Allows you to specify the starting column of the desired string.
  16.   * Adds a pause (/P) option to have the output pause every 24 lines.
  17.   * Avoids need to include the search string in quotation marks so you can  use
  18.     the program more easily in batch commands.
  19.   * The input file specification can  include  standard  DOS  wildcards  or  an
  20.     external file (@listfile) containing the files to be processed, e.g:
  21.           BFIND /I "SOUND" *.DOC > TEMP.X
  22.   * Allows you to recurse through child subdirectories.
  23.   * Allows you to skip the by-file heading information ("----- filename").
  24.   * Can avoid showing file name header if no hits in the file (/-EMPTY option).
  25.   * Handles DOS text files (lines end with CR/LF), Mac text  files  (lines  end
  26.     with CR), or Unix text files (lines end with LF).
  27.   * Should be able to handle input files with line lengths of  5000  characters
  28.     or more.  Should skip the remainder, allowing you to use the wildcards more
  29.     easily.
  30.   * Allows you to remove non-text characters from the output  or  even  specify
  31.     your own character-translation file for them.
  32.   * Pressing escape stops the program early.
  33.  
  34. The only FIND feature that BFIND does *not* support is the ability  to  specify
  35. multilple single input files  without  using  wildcards  ("FIND  ...  BRUCE.TXT
  36. BRUCE.DOC" works--"BFIND ... BRUCE.TXT BRUCE.DOC" does not).  In addition,  you
  37. cannot do piping into BFIND (for example: DIR | BFIND ...).
  38.  
  39. The DOS FIND command allows you to find lines in a text file  which  contain  a
  40. given string.  You can also have the program tell you how many  lines  met  the
  41. search criteria without actually viewing them which is an ideal way to find out
  42. how many times a given string appears in your file.  You can even use  FIND  to
  43. tell you how many total lines are in a given file just by requesting  a  string
  44. that you know will never appear in your file like  "#X$S$"  and  using  the  /C
  45. (count) parameter.
  46.  
  47. BFIND adds to these capabilities.  It gives you the power of AND, OR, NOT,  and
  48. XOR, allowing you to find any line, for example, that  contains  both  "Apples"
  49. and "Oranges" or to  present  any  lines  that  contain  either  "Bananas"  and
  50. "Pears".  In addition, you can do column-specific searching, finding only those
  51. lines, say, that contain "PRINT" beginning in column 10.
  52.  
  53. BFIND allows you to specify wildcards for the input file.  You can also put the
  54. list of file names to process in a text file and  tell  BFIND  to  process  the
  55. files listed therein.
  56.  
  57.  
  58.  
  59. BFIND.DOC                              2                           Jul 31, 1997
  60.  
  61. Defining Character-Translations (The Filter Table):
  62.  
  63. BFIND allows you to translate specified characters as the text is  read.   This
  64. is useful on output, when, for example, the text might contain things like page
  65. eject characters and you are rerouting the output to a printer; the page  eject
  66. characters would, of course, cause lots of extra pages to be printed.
  67.  
  68. There is a default character-translation table built into the program which you
  69. can request  by  passing  in  the  parameter  "/FILTER".   In  this  case,  all
  70. characters between decimal 32 and 126 as well as decimal 9 (the tab) keep their
  71. original values and everything else get translated as a space.  This leaves you
  72. with the following characters:
  73.  
  74.         (tab) (space)                   !"#$%&'()*+,-./
  75.         0123456789                      :;<=>?@
  76.         ABCDEFGHIJKLMNOPQRSTUVWXYZ      [\]^_`
  77.         abcdefghijklmnopqrstuvwxyz      {|}~
  78.  
  79. Alternatively, you can create your own filter file and invoke it by  specifying
  80. the "/FILTER=filename" parameter.  The filters can be in  your  standard  *.INI
  81. file (for example, BFIND.INI) if desired.  If it becomes  large,  however,  you
  82. might want to move it to its own filename.
  83.  
  84. The filter table is an ASCII text file which consists of a series of  lines  in
  85. the following format:
  86.  
  87.         inchar = outchar
  88.  
  89. where "inchar" is the character to change from and "outstr" is what  to  change
  90. the character to.  Both portions can consist of regular  non-space  ASCII  text
  91. characters (like "A" or "z") as well as hexadecimal values (in the  form  &Hxx)
  92. or decimal values (in the form  \nnn).   Both  sides  can  reference  a  single
  93. character  (exactly  one  character  is  always  translated  into  exactly  one
  94. character).  You cannot use a  space  or  equal  sign  in  either  "inchar"  or
  95. "outchar"; use the hexadecimal or decimal representations instead.   The  table
  96. does not have to be in any specified order.  Lines can end with  "/*"  followed
  97. by a comment if you want.
  98.  
  99. Hexadecimal and decimal equivalents are explained in BRUCEHEX.DOC.
  100.  
  101. Examples:
  102.  
  103.         a    = A   /* Translate lowercase "a" into capital "A"
  104.         \032 = _   /* Translate space (decimal 032, &H20 too) into underscore
  105.         \027 = \032    /* Translate escape character to a space
  106.  
  107. Some leading characters  in  INI  files  are  treated  specially  within  Wayne
  108. Software programs.  INI lines that begin with any of the  following  characters
  109. may lead to odd results:  "[", "/", "&", "\", ";", ":", "<", and ",".  To avoid
  110. problems, use hexadecimal or decimal representations for these characters.  For
  111. example, use \047 or &H2F if you want to override the definition of "/".
  112.  
  113.  
  114. BFIND.DOC                              3                           Jul 31, 1997
  115.  
  116. Specifying parameters:
  117.  
  118. Parameters for this program can be set in the following ways.  The last setting
  119. encountered always wins:
  120.   - Read from an *.INI file (see BRUCEINI.DOC file),
  121.   - Through the use of an environmental variable (SET BFIND=whatever), or
  122.   - From the command line (see "Syntax" below)
  123.  
  124.  
  125. Syntax:
  126.  
  127.     BFIND [ /V | /-V ] [ /C | /-C ] [ /N | /-N ] [ /I | /-I ] [ /P | /-P ]
  128.       [ /-HEADER ] [ /-EMPTY ] [ /FILTER | /FILTER=filename ]
  129.       [ /LINES { line1-line2 | line1 linect } ... ]
  130.       [ /ATTR=attribs ] [ /S ] [ /W | /W0 | /-W ]
  131.       [ /MONO ] [ /Iinitfile | /INULL ] [ /-ENV ] [ /? ] [ /?&H ]
  132.       { search } { filespec | @listfile } [ >filename ]
  133.  
  134. where:
  135.  
  136. "/V" says to find those items that do NOT match the  specification.   Initially
  137. defaults to "/-V".
  138.  
  139. "/-V" says to find those items  that  DO  match  the  specification.   This  is
  140. initially the default.
  141.  
  142. "/C" says to show the count of the items found (no individual lines). Initially
  143. defaults to "/-C".  One use for the "/C" parameter is to count  the  number  of
  144. lines in a file; search for all lines that do  *not*  (/V)  contain  a  totally
  145. improbable string and then tally them.  For example:
  146.  
  147.         BFIND /V /C "&^&^&#" MYFILE.TXT
  148.  
  149. "/-C" says to skip counting the items.  This is initially the default.
  150.  
  151. "/N" says to number the output lines.  Initially defaults to "/-N".
  152.  
  153. "/-N" says to skip numbering the output lines.  This is initially the default.
  154.  
  155. "/I" says to make it a case-insensitive search.  So a search for  "Apple"  will
  156. find "APPLE", "apple", ApPle", etc.
  157.  
  158. "/-I" is the opposite of /I and is typically the default.  A search for "Apple"
  159. will not find "APPLE".
  160.  
  161. "/P" says to have the display pause every  24  lines.   Initially  defaults  to
  162. "/-P".
  163.  
  164. "/-P" says to not bother pausing the output display.   This  is  initially  the
  165. default.
  166.  
  167.  
  168. BFIND.DOC                              4                           Jul 31, 1997
  169.  
  170. "/-HEADER" says to skip the normal -----infile output line that appears  before
  171. the results of the output.
  172.  
  173. "/HEADER" says to include the headers.  This is  initially  the  default.   The
  174. header lines look like this:
  175.  
  176.      --------- C:\VBDOS\BFIND.BAS
  177.  
  178. "/EMPTY" says that the -----infile header information is to be  shown  even  if
  179. the file doesn't have any hits in it.  This is initially the default.
  180.  
  181. "/-EMPTY" says to only show the -----infile header information if the file  has
  182. hits.  Initially defaults to "/EMPTY".
  183.  
  184. "/FILTER"  specifies  that  the  program  is  to  replace   with   spaces   all
  185. non-printable  characters  from  the  input   file(s).    See   the   "Defining
  186. Character-Translations" discussion above.  Initially defaults to "/-FILTER".
  187.  
  188. "/-FILTER" says to not bother removing the  nonprintable  characters  from  the
  189. output.  This is initially the default.
  190.  
  191. "/FILTER=filename" specifies that a filter is to be applied and  all  character
  192. replacements   are   in   the   file    "filename".     See    the    "Defining
  193. Character-Translations" discussion above.
  194.  
  195. "/LINES line1-line2" says to restrict the search to lines between line  numbers
  196. line1 and line2 inclusive.  You can have multiple line requests  in  any  order
  197. such as "/LINES 1-10 90-100 30-50".  The routine  skips  all  lines  after  the
  198. largest line number is encountered.  Defaults to "/LINES 1-9999999".
  199.  
  200. "/LINES line1 linect" says to restrict the search to lines beginning with line1
  201. and continuing for a total of linect lines.  So "/LINES 10 20" is actually  the
  202. same as "/LINES 10-29".
  203.  
  204. "/ATTR=attribs" allows you to specify a combination of attributes that you want
  205. considered.  You can specify any combination of R (read-only),  H  (hidden),  S
  206. (system), or A (archive bit).  Precede any character(s)  with  "-"  to  exclude
  207. instead of include.  Unlike with  the  DOS  DIR  command,  the  inclusions  and
  208. exclusions are subject to "OR" conditions; /ATTR=HS will retrieve any file that
  209. is either hidden or a system file or both.   You  can  specify  "/ATTR=ALL"  to
  210. specify that all files are to be processed.  Initially defaults to /ATTR=-H-S-R
  211. (skip hidden, system, or read-only files).
  212.  
  213. "/S"  processes  files  in  subdirectories  off  the  specified   subdirectory.
  214. Initially defaults to "/-S".
  215.  
  216. "/W" says to pause with a "Press any key to continue" message after the program
  217. finishes if any hits were found.  This parameter is ignored if redirection  out
  218. is being used.
  219.  
  220. "/W0" says to pause afterward whether any hits were  found  or  not.   This  is
  221. initially the default if the program is  run  under  Windows3.1  or  Windows95.
  222. BFIND won't detect if you're running under Windows NT though; you can  manually
  223. specify this parameter if the window closes up on you before you can  read  the
  224. results.  This parameter is ignored if redirection out is being used.
  225.  
  226.  
  227. BFIND.DOC                              5                           Jul 31, 1997
  228.  
  229. "/-W" says to not pause afterward at all.  This is initially the default if the
  230. program is run under DOS or Windows NT.
  231.  
  232. "/MONO" (or "/-COLOR") does not  try  to  override  screen  colors.   Initially
  233. defaults to "/COLOR".
  234.  
  235. "/COLOR" (or  "/-MONO")  allows  screen  colors  to  be  overridden.   This  is
  236. initially the default.
  237.  
  238. "/Iinitfile" says to read an initialization file with the file name "initfile".
  239. The file specification *must* contain a period.  Initfiles are described in the
  240. BRUCEINI.DOC file.  Initially defaults to "/IBFIND.INI".
  241.  
  242. "/INULL" says to skip loading the initialization file.
  243.  
  244. "/ENV" says to look for %var% occurrences  in  the  command  line  and  try  to
  245. resolve any apparent environmental variable references.  See  BRUCEINI.DOC  for
  246. more information.  This is initially the default.
  247.  
  248. "/-ENV" says to skip resolving apparent %var% occurrences in the command  line.
  249. Initially defaults to "/ENV".
  250.  
  251. "/?" or "/HELP" shows you the syntax for the command.  (Unlike with  the  other
  252. Wayne Software commands, "HELP" is not supported since the program  takes  this
  253. as your search string.)
  254.  
  255. "/?&H" gives you a hexadecimal and decimal conversion table.
  256.  
  257. "search" is described below.
  258.  
  259. "filespec" tells the routine which file or files  are  to  be  processed.   The
  260. specification can include path and wildcards if  desired.   One  thing  I  find
  261. useful  with  wildcards  is  that  is  allows  me  to  create  an  output  that
  262. concatenates all of the input files together with the typical headers (/HEADER)
  263. that separate each portion.  This requires searching for all lines in a file so
  264. you need to use the /V option and look for an improbable string.  For  example,
  265. to concatenate all *.TXT files together as a new file called TEMP.NEW and  have
  266. the little header between each, say this:
  267.  
  268.         BFIND /V "&#$#" *.TXT > TEMP.NEW
  269.  
  270. "@listfile" allows you to have a variety of file specifications saved in a text
  271. file named "listfile".  Each line in  the  file  should  consist  of  one  file
  272. specification, each of which can include a path and wildcards if desired. Blank
  273. lines and lines beginning with semi-colons, colons, or quotes are ignored.   An
  274. example using this is provided at the end of this documentation.
  275.  
  276. ">filename" redirects the output to a text file.   This  automatically  invokes
  277. the /-P option.  This is useful for saving the found lines into  another  file.
  278. For example:
  279.  
  280.         BFIND "Bruce" TEMP.TXT > TEMP2.TXT
  281.  
  282.  
  283.  
  284. BFIND.DOC                              6                           Jul 31, 1997
  285.  
  286. For search, the syntax is:
  287.  
  288.   [ ( ]... search_item [ boolean [ ( ]... search_item [ ) ]...] [ ) ]...
  289.  
  290. where:
  291.  
  292.   ( and )     are used to group items
  293.   search_item is shown below
  294.   boolean     is AND, OR, or XOR (NOT is included with search_item)
  295.  
  296. for search_item, the syntax is:
  297.  
  298.   [ NOT ]  "string" [ column ]
  299.  
  300. where:
  301.  
  302.   NOT         is obvious
  303.   string      the string to search; the quotation marks are typically not
  304.               required unless the string contains a space or a reserved word
  305.               or begins with a slash ("/")
  306.   column      is the column in which the string must be found.
  307.  
  308. So, let's cover some examples:
  309.  
  310.         BFIND "Bugs Bunny" OR "Elmer Fudd" TEST.TXT
  311.  
  312. Quotes are needed around a string if it begins with a slash:
  313.  
  314.         BFIND "/1997" TEST.TXT
  315.  
  316. Finds any lines in the file TEST.TXT containing either "Bugs Bunny"  or  "Elmer
  317. Fudd" in them.
  318.  
  319.         BFIND (Apples or Oranges) AND NOT Pears TEST2.TXT
  320.  
  321. Finds any lines in the file TEST2.TXT  which  contain  the  words  "Apples"  or
  322. "Oranges" in them and ignores any lines  containing  "Pears".   Note  that  the
  323. quotes around the search words are not required unless the words include spaces
  324. or unless they could be confused with some other keywords.  "BFIND  OR  OR  AND
  325. TEST3.TXT" might cause the program to get confused since "OR" and "AND",  which
  326. you want to look for, are also keywords.
  327.  
  328.         BFIND /C "Bugs Bunny" AND Martians TEST.TXT
  329.  
  330. Gives you a total for the number of lines  containing  both  "Bugs  Bunny"  and
  331. "Martians".
  332.  
  333. The search string can include any text characters.  It can also  contain  ASCII
  334. codes, created either using the Alt key in combination with the numeric  keypad
  335. (for example, Alt-228 to  get  a  Sigma  character)  or  else  by  embedding  a
  336. hexadecimal code (in the form &Hxx) or a decimal code (in the form \nnn) in the
  337. text.  These codes are described in the BRUCEHEX.DOC  file.   For  example,  to
  338. find the smiley face character  in  a  file  called  TEST.TXT,  either  of  the
  339. following work:
  340.  
  341.         BFIND "" TEST.TXT
  342.         BFIND \001 TEST.TXT
  343.  
  344. BFIND.DOC                              7                           Jul 31, 1997
  345.  
  346. If you search for more than one word without using a  Boolean  operator,  BFIND
  347. presumes you wanted the words searched with  an  "AND"  Boolean  operator.   So
  348. this:
  349.  
  350.         BFIND Print Form *.TXT
  351.  
  352. is the same thing as saying:
  353.  
  354.         BFIND Print AND Form *.TXT
  355.  
  356. If you wanted to search for the *phrase* "Print Form", you'd have to say:
  357.  
  358.         BFIND "Print Form" *.TXT
  359.  
  360. You can press the Esc key to abort the search early.
  361.  
  362. BFIND, unlike FIND, typically doesn't  require  the  search  string  to  be  in
  363. quotes. As  a  result,  you  can  create  a  text  file  (presume  it's  called
  364. C:\BAT\PHONE.TXT) containing phone numbers or something and then create a batch
  365. file (like PHONE.BAT) that looks like this:
  366.  
  367.         BFIND %1 %2 %3 %4 %5 C:\BAT\PHONE.TXT
  368.  
  369. When you want to find a phone number, you just say "PHONE  name".   This  is  a
  370. little more natural that using FIND which would require that  you  enclose  the
  371. name in quotes.  You can still use the Boolean operators in  BFIND;  the  batch
  372. file above would allow up to five parameters.
  373.  
  374. If you have multiple phone books, use the @listfile option in the  batch  file.
  375. For example, I have four phone files I search; a personal one  (PHONES.TXT),  a
  376. list of e-mail addresses (PHONMAIL.TXT), a list of work-related  phone  numbers
  377. that  are  distributed  to  the  office  (EBBPHONE.TXT),  and  an  office  list
  378. (OBAPHONE.TXT).  My @listfile is called C:\MINE\PHONE.LST  and  contains  these
  379. lines:
  380.  
  381.         c:\mine\phones.txt
  382.         c:\mine\phonmail.txt
  383.         c:\mine\ebbphone.txt
  384.         c:\mine\obaphone.txt
  385.  
  386. My PHONE.BAT file contains this line:
  387.  
  388.         BFIND /I /P /-EMPTY %1 %2 %3 %4 @C:\MINE\PHONE.LST
  389.  
  390.  
  391.  
  392. BFIND.DOC                              8                           Jul 31, 1997
  393.  
  394. Return codes:
  395.  
  396. BFIND returns the following ERRORLEVEL codes:
  397.         0 = no problems, string found
  398.         1 = no problems, string not found
  399.       250 = operation aborted by pressing Escape
  400.       255 = syntax problems, file not found, or /? requested
  401.  
  402.  
  403. Author:
  404.  
  405. This program was written by Bruce Guthrie of Wayne Software.  It  is  free  for
  406. use and  redistribution  provided  relevant  documentation  is  kept  with  the
  407. program, no changes are made to the program or documentation,  and  it  is  not
  408. bundled with commercial programs or charged for separately.  People who need to
  409. bundle it in for-sale packages must  pay  a  $50  registration  fee  to  "Wayne
  410. Software" at the following address.
  411.  
  412. Additional information about this and other  Wayne  Software  programs  can  be
  413. found in the file BRUCE.DOC which should be included in the original ZIP  file.
  414. The recent change history for this and the other programs is  provided  in  the
  415. HISTORY.ymm file which should be in the same ZIP file where "y" is replaced  by
  416. the last digit of the year and "mm" is the two  digit  month  of  the  release;
  417. HISTORY.611 came out in November 1996.  This same naming convention is used  in
  418. naming the ZIP file (BFINDymm.ZIP) that this program was included in.
  419.  
  420. Comments and suggestions can also be sent to:
  421.  
  422.                 Bruce Guthrie
  423.                 Wayne Software
  424.                 113 Sheffield St.
  425.                 Silver Spring, MD 20910
  426.  
  427.                 e-mail: WayneSof@erols.com   fax: (301) 588-8986
  428.                 http://www.geocities.com/SiliconValley/Lakes/2414
  429.  
  430. Please provide an Internet e-mail address on all correspondence.
  431.  
  432. 
  433.